A computer system may sometimes have a need to evacuate the content of one or more pages of memory. For example, when it is suspected that a page of memory may be defective, it is desirable to remove that page of memory from use. As another example, in a computer with multiple partitions, it may be useful to assign a page of memory from one partition to another partition (for load balancing, for example). Since the page of memory to be removed or reassigned may be accessed by executing processes and/or devices, it is necessary to properly evacuate the content of the memory page so that such executing processes and/or devices can continue with minimal disruption vis-a-vis a new memory page.
To facilitate discussion, FIG. 1 shows an example computer system 102, including a CPU 104, an I/O module 106, and a memory module 108, all connected via a bus 110. Computer 102 is intended to be illustrative and is thus vastly simplified. In reality, computer 102 may represent a computer system with multiple CPUs, multiple I/O modules, multiple memory modules, and may have its components dispersed geographically among different enclosures. A bus-based architecture is also not a requisite feature of computer system 102.
Memory module 108 is typically implemented using some type of semiconductor memory for fast access. Within memory module 108, there are shown a plurality of pages A-L. In the example of FIG. 1, memory pages A, E, F, H, and K have contents stored in them. The contents in these memory pages A, E, F, H, and K may be utilized by processes executing using CPU 104, for example. Memory pages B, C, G, I, J, and L are shown to be free memory pages. Memory evacuation refers to the process of transferring or copying the content from a source memory page (e.g., the content from memory page A) to a destination memory page (e.g., memory page C) so that the source memory page can be freed up after the evacuation process is complete. For simplicity, the source memory page and the destination memory page belong to the same memory module in the example of FIG. 1. In fact, memory evacuation works even if memory pages are dispersed among different memory modules.
At a high level, memory evacuation appears to be a fairly straight forward procedure. However, reliable and robust memory evacuation involve handling the myriads of operating system-specific situations, the details of which vary from operating system to operating system, and all of which need to be properly handled. For example, memory evacuation involves algorithms for properly selecting the target free memory page (e.g., memory page C) for optimum performance, properly locking and unlocking memory pages during the evacuation operation (e.g., to prevent other processes from accessing the target memory page and/or the source memory page during the evacuation operation), handling edge conditions such as pending memory I/O accesses by the source memory page or concurrent sharing of the source memory page, etc.
A brute force approach to implementing memory evacuation may involve creating code that would properly handle all of the aforementioned situations, as well as other situations that may impact the memory evacuation procedure. However, such a brute force approach necessarily involves extensive coding and testing to ensure that all situations are properly handled. The time-consuming processes of coding and testing need to be repeated for different operating systems since, as mentioned earlier, the details pertaining to memory allocation and/or memory content transfer may vary from operating system to operating system.